import struct
import os

# 定义要写入的数据
data = [0xaa]+[0xbb]+[0xcc]+[0xdd]+[0xee]+[0xff]+[0x00]*8+[0x01]+[0x01]+[0x01]+[0x00]*4+[0x02]+[0x71]+[0X00] * 300+[0XFF]*12 + [0XF0] +[0x00]*249+ [0x0F] +[0XFF]* 62  +[0x00]
data2 = [0xaa]+[0xbb]+[0xcc]+[0xdd]+[0xee]+[0xff]+[0x00]*8+[0x01]+[0x01]+[0x01]+[0x00]*4+[0x02]+[0x71]+[0XFF] * 25+[0x00]*600  +[0x00]
data3 = [0xaa]+[0xbb]+[0xcc]+[0xdd]+[0xee]+[0xff]+[0x00]*8+[0x01]+[0x01]+[0x02]+[0x00]*4+[0x02]+[0x71]+[0X00] * 300+[0XFF]*12 + [0XF0] +[0x00]*249+ [0x0F] +[0XFF]* 62  +[0x00]

data3 = [0xaa]+[0xbb]+[0xcc]+[0xdd]+[0xee]+[0xff]+[0x00]*8+[0x01]+[0x01]+[0x02]+[0x00]*4+[0x02]+[0x71]+[0X00] * 300+[0XFF]*12 + [0XF0] +[0x00]*249+ [0x0F] +[0XFF]* 62  +[0x00]
ch2_20fps = [0xaa]+[0xbb]+[0xcc]+[0xdd]+[0xee]+[0xff]+[0x00]*8+[0x01]+[0x01]+[0x02]+[0x00]*4+[0x04]+[0xe2]+[0X00] * 612+[0X0f]+[0XFF]*12 + [0X00]*562 +[0x0f] +[0XFF]* 62  +[0x00]
ch1_20fps = [0xaa]+[0xbb]+[0xcc]+[0xdd]+[0xee]+[0xff]+[0x00]*8+[0x01]+[0x01]+[0x01]+[0x00]*4+[0x04]+[0xe2]+[0X00] * 612+[0XF0]+[0XFF]*12 + [0X00]*562 +[0x0f] +[0XFF]* 62  +[0x00]

ch2_10fps = [0xaa]+[0xbb]+[0xcc]+[0xdd]+[0xee]+[0xff]+[0x00]*8+[0x01]+[0x01]+[0x02]+[0x00]*4+[0x09]+[0xC4]+[0X00] * 1237+[0X0f]+[0XFF]*12 + [0X00]*1187 +[0x0f] +[0XFF]* 62  +[0x00]

# 定义输出文件名
output_file = 'C:/Users/huang.wenjie/prj/timing_gen/sim/ch2_10fps.bin'

# 打开二进制文件
with open(output_file, 'wb') as f:
    for bit in ch2_10fps:
        # 将1和0转换为字节并写入文件
        f.write(struct.pack('B', bit))

# 获取文件的绝对路径
output_path = os.path.abspath(output_file)
print(f"二进制文件生成完毕，路径为：{output_path}")